home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / dev / gcc / ixemul_src.lha / ixemul-41.0 / stack / init_stk.c < prev    next >
C/C++ Source or Header  |  1995-05-23  |  1KB  |  45 lines

  1. #include <proto/exec.h>
  2. #include <proto/dos.h>
  3. #include <stabs.h>
  4.  
  5. #if 0    /* Unused? */
  6. extern APTR __SaveSP;
  7. #endif
  8.  
  9. extern ULONG __stk_safezone;
  10.  
  11. APTR  __stk_limit=NULL;
  12. APTR *__stackborders=NULL;
  13.  
  14. /*
  15.  * This way to find the bottom of the current stackframe
  16.  * is the way descibed in the amiga-guru-book.
  17.  *
  18.  * Note that it's of no use to check if the actual parameters are set
  19.  * correctly (disabling stackextension if not) because a program will
  20.  * crash anyway in that case (if you check against the wrong border or
  21.  * not at all).
  22.  * But with wrong parameters you can probably raise a stackextend too
  23.  * soon - thus gaining *correct* (for following stackextends) stackbounds
  24.  * at the cost of only some memory.
  25.  */
  26.  
  27. void __init_stk(void)
  28. {
  29.   struct Process *me;
  30.   APTR sl;
  31.  
  32.   me=(struct Process *)FindTask(NULL);
  33.   __stackborders=&me->pr_Task.tc_SPLower;
  34.   if(me->pr_CLI)
  35.     sl=(char *)me->pr_ReturnAddr /*+sizeof(ULONG)*/ -*(ULONG *)me->pr_ReturnAddr;
  36.   else                      /*^^^^^^^^^^^^^^ need not be that precise */
  37.     sl=&me->pr_Task.tc_SPLower;
  38.   sl+=__stk_safezone;
  39.   __stk_limit=sl;
  40. }
  41.  
  42. #if 0    /* ixemul crt0.c calls this directly -fnf */
  43. ADD2INIT(__init_stk,-50);
  44. #endif
  45.